﻿<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <input type="text" name="name" value="" />
    <input type="text" name="name" value="" />
    <input type="text" name="name" value="" />
    <input type="text" name="name" value="" />
    <input type="text" name="name" value="" />
    <input type="text" name="name" value="" />
    <input type="text" name="name" value="" />
    <input type="text" name="name" value="" />
    <input type="text" name="name" value="" />
    <input id="btn" type="button" name="name" value="获取文本框的值" />
    <script>
        all_input = document.querySelectorAll('input');
        for (var i = 0; i < all_input.length; ++i) {
            var input = all_input[i];
            if (input.type === 'text') {
                input.value = i;
            }
        }

        btn = document.querySelector('#btn');
        btn.onclick = function () {
            var array = []
            for (var i = 0; i < all_input.length; ++i) {
                var input = all_input[i];
                if (input.type === 'text') {
                    array.push(input.value)
                }
            }
            console.log(array.join('|'))
        }
    </script>
</body>
</html>